(function () {
    var module = {};
    var tools = Tools();

    module.init=function () {
        tools.getUserInfo();
        $("#alertMessage").fadeIn();

        //获取银行卡信息
        tools.doGet(accountURL+tools.apiURL.bankCard,{},module.bankCard)

    };


    module.bankCard=function (data) {
        if (data.status == 0) {
            if (data.data != null) {
                var content = data.data;
                $('.cardNum').text(content.cardNo);
                $('.bankIcon').attr('src', content.icon);
                $('.bankN').text(content.name);
                if (content.status == 0) {
                    $('#mIndex3').show();
                } else if (content.status == 1) {
                    $('#mIndex').show();
                    $(document).on('click', '#unbundlingBank', function () {
                        tools.doGet(accountURL +tools.apiURL.buildUnbindBankcardParms, {}, module.buildUnbindBankcardParms);
                    });
                } else if (content.status == 2) {
                    $('#mIndex2').show();
                }
            }else{ 
                $('#mIndex1').show();
                //未开银行卡
                $(document).on('click', '.addBank_b', function () {
                    tools.doGet(accountURL + tools.apiURL.buildChangeBankcardParms, {isChange: false}, module.buildUnbindBankcardParms1);
                })
            }
        }
    };

        module.buildUnbindBankcardParms=function (data) {
            if(data.status==0){
                tools.formPost(data.data.actionUrl, data.data.parms);
            }else{
                $("#alertMessage").fadeIn();
                $("#message").text(data.message);
                setTimeout(function(){
                    $("#alertMessage").fadeOut();
                },2000)
            }
        };
        module.buildUnbindBankcardParms1=function (data) {
            if(data.status==0){
                tools.formPost(data.data.actionUrl, data.data.parms);
            }else{
                $("#alertMessage").fadeIn();
                $("#message").text(data.message);
                setTimeout(function(){
                    $("#alertMessage").fadeOut();
                },2000)
            }
        };

    module.init();
})();